<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>客户群群发</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/hyqcss/public.css">
	<style type="text/css">
		body{
			background: #e9e9e9;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
		}
		.public_buttonSearch_container{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20px;
			background: #fff;
		}
		.public_buttonSearch_container a{
			color: #fff;
			background-color: #1E9FFF;
			text-shadow: 0 -1px 0 rgba(0,0,0,.12);
			height: 24px;
			padding: 4px 15px;
			font-size: 14px;
			border-radius: 2px;
			display: flex;
			align-items: center;
		}
		.public_Search_container{
			position: relative;
		}
		.public_Search_container input{
			width: 240px;
			height: 32px;
			border: 1px solid #d9d9d9;
		}
		.public_Search_container i{
			position: absolute;
			bottom: 6px;
			right: 10px;
			cursor: pointer;
		}
		/*公共头部带搜索 end*/
		
	</style>
</head>
<body>
	
	<div class="public_container">
		<!-- /*公共头部带搜索*/ -->
		<div class="public_content">
			<div class="public_title_container">
				<p>客户群群发</p>
			</div>
			<div class="public_buttonSearch_container">
				<a href="add_group_msg_task.html">+ 新建群发</a>
				<form  method="get" action="" id="Form1">
				<div class="public_Search_container">
					<input type="text" name="name" value="{$name}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
					<i class="layui-icon layui-icon-search" onclick="document.getElementById('Form1').submit()"></i>
				</div>
				</form>
			</div>
		</div>
		<!-- /*公共头部带搜索*/ end -->
		<!-- 公共表格部分 -->
		<div class="public_table_container">
			<table class="layui-table" lay-skin="line">
			  <colgroup>
			      <col>
			      <col width="100">
			      <col>
			      <col width="100">
			      <col width="100">
			      <col>
			      <col width="160">
			      <col width="100">
			      <col width="100">
			    </colgroup>
			    <thead>
			      <tr>
			        <th>群发名称</th>
			        <th>发送群主</th>
					<th>发送文本内容</th>
			        <th>群发类型</th>
			        <th>发送时间</th>
			        <th>发送详情</th>
			        <th>创建时间</th>
			        <th>状态</th>
			        <th>操作</th>
			      </tr> 
			    </thead>
			    <tbody>
				{loop $res as $r}
				<tr>
			        <td>{$r->name}</td>
			        <td>
						{loop $r->owners as $o}
							{$o['name'] }<br/>
						{/loop}
					</td>
					<td>
						{$r->text_content }
					</td>
					<td>
						{$r->sendType }
					</td>
			        <td>
					{if $r->send_mode == 1}
					立即发送
					{elseif $r->send_mode == 2}
					定时发送({date('Y-m-d H:i',strtotime($r->timing_time))})
					{/if}
					</td>
					<td>
						{loop $r->details as $d}
							群主：{$d['owenerName']}，成功发送群聊数量：{$d['success_num'] ?: 0 }<br/>
						{/loop}
					</td>
			        <td>{$r->ctime}</td>
			        <td>
					{if $r->status == 0}
					发送中
					{elseif $r->status == 1}
					发送成功
					{elseif $r->status == 2}
					发送失败
					{elseif $r->status == 3}
						待发送
					{/if}
					</td>
					<td>
						{if $r->status == 3}
							<a href="javascript:;" class="table-public-btn" onclick='del_task( {$r->id} )'>删除</a>
						{/if}
						{if $r->status != 2 || $r->status != 3}
							<a href="javascript:;" class="table-public-btn" onclick='refResultInfo( {$r->id} )'>同步数据</a>
						{/if}
					</td>
			        <!--<td><button type="button" class="layui-btn layui-btn-sm layui-btn-danger">查看结果</button></td>-->
			      </tr>
				{/loop}

			    </tbody>
			</table>
		</div>
		<!-- 公共表格部分 end-->
		<div class="main-container-h pageing-container-h">
		        <div class="pageing-content-h">
		           <span>{$P->totalnum}条/{$P->totalpage}页</span>
		        </div>
				<ul class="pageing-content-h">
		           {P weidogsadmin}
				</ul>
		    </div>
	</div>
	
	<script src="/cdn/jquery.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
		function del_task(tid){
			if(confirm('确定删除吗？')) {
				myAjaxPost(false, true, 'del_group_task.html', { gid:tid},  (resp) => {
					if (resp.status == 'success') {
						tusi(resp.msg);
						setTimeout(function(){
							location.href = 'group_send_manage.html';
						},500);
					}else{
						alert(resp.msg);
					}
				});
			}
		}
		function refResultInfo(id){
			if(confirm('确定更新本条数据吗？')) {
				myAjaxPost(false, true, 'ref_task_info.html', { gid:id},  (resp) => {
					if (resp.status == 'success') {
						tusi(resp.msg);
						setTimeout(function(){
							location.href = 'group_send_manage.html';
						},500);
					}else{
						alert(resp.msg);
					}
				});
			}
		}
	</script>
</body>
</html>